package com.longrise.android.byjk.plugins.poster.presenter;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.common.UrlConstants;
import com.longrise.android.byjk.plugins.poster.PosterListView;
import com.longrise.android.loaddata.newloaddata.LoadDataManagerFather;
import com.longrise.common.base.BasePresenter;
import com.longrise.common.datasource.remote.LoadDataManager;
import com.longrise.common.utils.PrintLog;

/**
 * Created by godliness on 2017/9/25.
 */

public class PosterDataPresenter extends BasePresenter<PosterListView> {

    @Override
    protected void init() {
    }

    public void getListData(String type) {
        EntityBean bean = new EntityBean();
        bean.set("goodstype", type);
        PrintLog.e("details type", " type = " + type);
        bean.set("pagenum", "0");
        bean.set("pagesize", "15");
        EntityBean fbean = new EntityBean();
        fbean.set("bean", bean);
        LoadDataManager.getInstance().callService2(null, UrlConstants.BaseUrl, "bbt_vip_sPostersInfoBygoodstype", fbean, new LoadDataManager.OnRequestCallListener2() {

            @Override
            public void onSuccess(String key, String service, Object result) {
                try {
                    EntityBean bean = (EntityBean) result;
                    String resultdesc = bean.getString("resultdesc");
                    int value = (Integer) bean.get("resultstate");
                    PrintLog.e("details value", " value = " + value);
                    if (value == 1) {
                        EntityBean[]  resultbean = bean.getBeans("result");
                        mView.showData(resultbean);
                        PrintLog.e("details resultbean", " resultbean = " + resultbean.length);
                    } else {
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {

            }

            @Override
            public void onFinished(String key, String service) {
            }


        });
    }

}
